Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/storage

Package Overview
Dependencies
Maintainers
1
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/storage

Cloud Storage Client Library for Node.js

  • 5.20.5
  • legacy-10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5M
decreased by-9.45%
Maintainers
1
Weekly downloads
 
Created

What is @google-cloud/storage?

The @google-cloud/storage npm package is a client library for using Google Cloud Storage, which is a service for storing and accessing data on Google's infrastructure. The package allows Node.js developers to interact with Google Cloud Storage in a server-side application.

What are @google-cloud/storage's main functionalities?

Uploading files

This feature allows users to upload files to a Google Cloud Storage bucket. The code sample demonstrates how to upload a local file to a specified bucket.

const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
async function uploadFile() {
  await storage.bucket('my-bucket').upload('local-file-path', {
    destination: 'destination-file-path',
  });
  console.log('File uploaded.');
}
uploadFile().catch(console.error);

Downloading files

This feature enables users to download files from a Google Cloud Storage bucket. The code sample shows how to download a file from a bucket to the local file system.

const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
async function downloadFile() {
  const options = {
    destination: 'local-file-path',
  };
  await storage.bucket('my-bucket').file('remote-file-path').download(options);
  console.log('File downloaded.');
}
downloadFile().catch(console.error);

Listing files

This feature provides the ability to list all files in a Google Cloud Storage bucket. The code sample lists the names of all files in a specified bucket.

const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
async function listFiles() {
  const [files] = await storage.bucket('my-bucket').getFiles();
  files.forEach(file => console.log(file.name));
}
listFiles().catch(console.error);

Deleting files

This feature allows users to delete files from a Google Cloud Storage bucket. The code sample demonstrates how to delete a specific file from a bucket.

const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
async function deleteFile() {
  await storage.bucket('my-bucket').file('file-to-delete').delete();
  console.log('File deleted.');
}
deleteFile().catch(console.error);

Managing buckets

This feature enables users to manage buckets, including creating and deleting buckets. The code sample shows how to create a new bucket in Google Cloud Storage.

const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
async function createBucket() {
  await storage.createBucket('new-bucket');
  console.log('Bucket created.');
}
createBucket().catch(console.error);

Other packages similar to @google-cloud/storage

Keywords

FAQs

Package last updated on 19 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc